<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript" src="../js/jquery-3.5.1.min.js"></script>
<script language="javascript" type="text/javascript">
    function Time() {
        //获取元素当前数字
        var time = $("#Time").text();
        if (time == 1) {//进行判断
            $("div").remove();
            var seckill =document.getElementById("seckill");
            login.style.display="block";
        } else {
            time = time - 1;
            $("#Time").text(time);//最新数字进行赋值
        }
    }
    setInterval(Time, 1000);//每隔1秒执行一次Time方法

    function seckill(){
        $.ajax({
            type: "POST",
            url: "http://188.131.243.12/seckill/click",
            success: function (data) {
                if(data.msg=="error"){
                    alert("商品已售完");
                }else{
                    window.location.href="pay.html?id="+data.msg;
                }
            }
        });
    }
</script>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>秒杀</title>
</head>
<body onload="Time()">
<div id="dic">5秒后开始秒杀:</div>
<div id="Time">6</div>
<input id="seckill" type="button" value="秒杀" style="display: none" onclick="login()"/>
</body>
</html>